import 'package:flutter/material.dart';

/// FileName common_page
///
/// @Author lax
/// @Date 2024/6/4
///
/// @Description

class CommonPage extends StatefulWidget {
  final String? title;

  final bool showAppBar;

  final PreferredSizeWidget? appBarBottom;

  final Widget? body;

  final Widget? bottomNavigationBar;

  final Widget? bottomSheet;

  const CommonPage({
    super.key,
    this.title,
    this.showAppBar = true,
    this.appBarBottom,
    this.body,
    this.bottomNavigationBar,
    this.bottomSheet,
  });

  @override
  State<StatefulWidget> createState() {
    return _CommonPageState();
  }
}

class _CommonPageState extends State<CommonPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: widget.showAppBar
          ? AppBar(
              leading: TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: const Icon(Icons.arrow_back_ios),
              ),
              title: Text(widget.title ?? ''),
              centerTitle: true,
              backgroundColor: Colors.lightGreen,
              bottom: widget.appBarBottom,
            )
          : null,
      body: widget.body ?? const SizedBox.shrink(),
      bottomNavigationBar: widget.bottomNavigationBar,
      bottomSheet: widget.bottomSheet,
    );
  }
}
